#ifndef ORIGIN_IMAGE_MODEL_H
#define ORIGIN_IMAGE_MODEL_H

#include <string>
#include <vector>
#include "ImageType.hpp"
#include <functional>
#include "POSIX_Semaphore.hpp"
#include "POSIX_SharedMemory.hpp"
#include "POSIX_MessageQueue.hpp"
#include <pthread.h>
#include <thread>

class OriginImageModel
{
  public:
    OriginImageModel(const std::string & configPath,std::function<void(const std::vector<ImageType> &)> func);
    virtual ~OriginImageModel();
    void Boot();
    void StartRecode(const std::string & path);
    void StopRecode();
    void StartMonitor();
    void StopMonitor();
    bool RecordStatus();
    bool MonitorStatus();
  private:
    POSIX_MessageQueue controlMsgQueue;
    std::function<void(const std::vector<ImageType> &)> newImageCallback;
    long memSize;
    std::vector<POSIX_SharedMemory> sharedMemoryList;
    std::unique_ptr<POSIX_Semaphore> memory_lock;
    void GetMemoryCallback(std::string val);
    pthread_t threadID;
    std::thread workThread;
};

#endif
